String clazzTpl({package}) => """
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:$package/route/main.route.dart';

/// 请叫我code哥
/// Generates Dart code
class ScreenSizeFit {
  static late MediaQueryData mediaQueryData;
  static late double screenWidth;
  static late double screenHeight;
  static late double textScaleFactor;
  static late double rpx;
  static late double px;

  static void init(BuildContext? context, {double width = 750}) {
    mediaQueryData =
        MediaQuery.of(context ?? globalNavigatorKey.currentState!.context);
    screenWidth = mediaQueryData.size.width;
    screenHeight = mediaQueryData.size.height;
    textScaleFactor = mediaQueryData.textScaleFactor;
    rpx = screenWidth / width;
    px = screenWidth / width * 2;
  }

  /// 按照像素来设置
  static double _setPx(double size) => ScreenSizeFit.px * size;

//  /// 按照rxp来设置 1rpx=屏幕宽度/750
//  static double _setRpx(double size) => ScreenSizeFit.rpx * size;
}

///使用方式 SizeConstant.size_px_20 / SizeConstant.size_sp_16
extension ScreenSizeExtension on num {
  ///设置宽高大小
  double get px => ScreenSizeFit._setPx(this.toDouble());

  ///设置文字大小
  double get sp =>
      ScreenSizeFit._setPx(this.toDouble()) * ScreenSizeFit.textScaleFactor;

  ///设置实际像素大小
  ///例如 1像素 SizeConstant.size_pix_1
  double get pix => this.toDouble() / window.devicePixelRatio;
}
""";
